package com.wcy.service.impl;

import com.wcy.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wcy.domain.SysMenu;
import com.wcy.mapper.SysMenuMapper;
import com.wcy.service.SysMenuService;
/**
 * <p>Title:SysMenuServiceImpl.java</p >
 * <p>Description: </p >
 * <p>Copyright: 公共服务与应急管理战略业务本部 Copyright(c)2020</p >
 * <p>Date:2021/9/18 22:14</p >
 *
 * @author wcy (wangchaoyanga@mail.taiji.com.cn)
 * @version 1.0
 */
@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService{

    @Autowired
    private SysRoleService sysRoleService;

    @Autowired
    private SysMenuMapper sysMenuMapper;

    @Override
    public List<SysMenu> getMenusByUserId(Long userId) {
        // 如果该用户为超级管理员 ->> 拥有所有菜单
        if(sysRoleService.isSuperAdmin(userId)){
            return list();
        }
        // 如果不是超级管理员 ->> 查询角色 ->> 查询菜单
        return sysMenuMapper.selectMenusByUserId(userId);
    }
}
